package com.ttwl.www.app.meFrame.personInfoFrame;


import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.ttwl.www.app.R;
import com.ttwl.www.app.widget.CustomDialog;

public class personInfoActivity extends AppCompatActivity {
    public static final int TAKE_PHOTO = 1;
    public static final int CHOOSE_PHOTO = 2;
    private ImageView goBack;
    private LinearLayout lNickName,lPic,lPersonalHomePage;
    private Button mBtnDialog;
    private Uri imageUri;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_person_info);
        goBack = (ImageView) findViewById(R.id.go_back);
        goBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        lNickName = (LinearLayout) findViewById(R.id.l_nick_name);
        lPic = (LinearLayout) findViewById(R.id.l_pic);
        lPersonalHomePage = (LinearLayout) findViewById(R.id.l_personal_homePage);
        //更改头像
        lPic.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //实例化customDialog
                CustomDialog customDialog = new CustomDialog(personInfoActivity.this);
                customDialog.setPhoto("从相册选择", new CustomDialog.IOnPhotoListener() {
                    @Override
                    public void onPhoto(CustomDialog dialog) {
                        Toast.makeText(personInfoActivity.this,"选择~",Toast.LENGTH_SHORT).show();
                    }
                }).setCamera("拍照", new CustomDialog.IOnCameraListener() {
                    @Override
                    public void onCamera(CustomDialog dialog) {
                        Toast.makeText(personInfoActivity.this,"拍照了~",Toast.LENGTH_SHORT).show();
                    }
                }).setCancel("取消", new CustomDialog.IOnCancelListener() {
                    @Override
                    public void onCancel(CustomDialog dialog) {
                        Toast.makeText(personInfoActivity.this,"取消了~",Toast.LENGTH_SHORT).show();
                    }
                }).show();

            }
        });
        //跳转activity
        setListeners();
    }
    private void setListeners() {
        OnClick onClick = new OnClick();
        lNickName.setOnClickListener(onClick);
        lPersonalHomePage.setOnClickListener(onClick);
    }

    private class OnClick implements View.OnClickListener{
        @Override
        public void onClick(View v) {
            Intent intent = null;
            switch (v.getId()) {
                case R.id.l_nick_name:
                    //跳转到修改昵称界面
                    intent = new Intent(personInfoActivity.this,changeNickNameActivity.class);
                    break;
                case R.id.l_personal_homePage:
                    //跳转到修改昵称界面
                    intent = new Intent(personInfoActivity.this,PersonalHomePageActivity.class);
                    break;
            }
            startActivity(intent);
        }
    }
}
